package com.ktgj.service.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.service.domain.ContractLinkAirportservicePrice;
import com.ktgj.service.service.IContractLinkAirportservicePriceService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 合同机场服务价格Controller
 * 
 * @author ruoyi
 * @date 2021-09-03
 */
@ControllerAdvice
@RestController
@RequestMapping("/prices")
public class ContractLinkAirportservicePriceController extends BaseController
{
    @Autowired
    private IContractLinkAirportservicePriceService contractLinkAirportservicePriceService;

    /**
     * 查询合同机场服务价格列表
     */
    @PreAuthorize(hasPermi = "service:price:list")
    @GetMapping("/list")
    public TableDataInfo list(ContractLinkAirportservicePrice contractLinkAirportservicePrice)
    {
        startPage();
        List<ContractLinkAirportservicePrice> list = contractLinkAirportservicePriceService.selectContractLinkAirportservicePriceList(contractLinkAirportservicePrice);
        return getDataTable(list);
    }

    /**
     * 导出合同机场服务价格列表
     */
    @PreAuthorize(hasPermi = "service:price:export")
    @Log(title = "合同机场服务价格", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ContractLinkAirportservicePrice contractLinkAirportservicePrice) throws IOException
    {
        List<ContractLinkAirportservicePrice> list = contractLinkAirportservicePriceService.selectContractLinkAirportservicePriceList(contractLinkAirportservicePrice);
        ExcelUtil<ContractLinkAirportservicePrice> util = new ExcelUtil<ContractLinkAirportservicePrice>(ContractLinkAirportservicePrice.class);
        util.exportExcel(response, list, "合同机场服务价格数据");
    }

    /**
     * 获取合同机场服务价格详细信息
     */
    @PreAuthorize(hasPermi = "service:price:query")
    @GetMapping(value = "/{contractAirportServicePriceId}")
    public AjaxResult getInfo(@PathVariable("contractAirportServicePriceId") Long contractAirportServicePriceId)
    {
        return AjaxResult.success(contractLinkAirportservicePriceService.selectContractLinkAirportservicePriceById(contractAirportServicePriceId));
    }

    /**
     * 新增合同机场服务价格*/
    @PreAuthorize(hasPermi = "service:price:add")
    @Log(title = "合同机场服务价格", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ContractLinkAirportservicePrice contractLinkAirportservicePrice)
    {
        return toAjax(contractLinkAirportservicePriceService.insertContractLinkAirportservicePrice(contractLinkAirportservicePrice));
    }

    /**
     * 修改合同机场服务价格*/
    @PreAuthorize(hasPermi = "service:price:edit")
    @Log(title = "合同机场服务价格", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ContractLinkAirportservicePrice contractLinkAirportservicePrice)
    {
        return toAjax(contractLinkAirportservicePriceService.updateContractLinkAirportservicePrice(contractLinkAirportservicePrice));
    }

    /**
     * 删除合同机场服务价格*/
    @PreAuthorize(hasPermi = "service:price:remove")
    @Log(title = "合同机场服务价格", businessType = BusinessType.DELETE)
	@DeleteMapping("/{contractAirportServicePriceIds}")
    public AjaxResult remove(@PathVariable Long[] contractAirportServicePriceIds)
    {
        return toAjax(contractLinkAirportservicePriceService.deleteContractLinkAirportservicePriceByIds(contractAirportServicePriceIds));
    }
}
